package com.fr.schedule.web;

import com.fr.data.impl.sap.SAPTransferManager;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.web.core.ActionNoSessionCMD;
import com.fr.web.utils.WebUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.Iterator;

public class ScheduleGetAllTransfersAction extends ActionNoSessionCMD {

	public void actionCMD(HttpServletRequest req, HttpServletResponse res) throws Exception {
		PrintWriter printWriter = WebUtils.createPrintWriter(res);
		
		JSONArray ja = new JSONArray();
		Iterator it = SAPTransferManager.getInstance().getSAPTransferNameIterator();
		
		JSONObject jo;
		Object obj;
		while (it.hasNext()) {
			jo = new JSONObject();
			obj = it.next();
			jo.put("text", obj);
			jo.put("value", obj);
			ja.put(jo);
		}
		
		printWriter.print(ja.toString());
		
		printWriter.flush();
		printWriter.close();
	}

	public String getCMD() {
		return "se_getalltransfers";
	}
}
